﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefProdBatchMaterialRecord" :model="stateProdBatchMaterialRecord.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialCode_FormItem" prop="Entity.MaterialCode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_MaterialCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdBatchMaterialRecord_MaterialCode')}), trigger: 'blur' }]" >
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.MaterialCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Barcode_FormItem" prop="Entity.Barcode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_Barcode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdBatchMaterialRecord_Barcode')}), trigger: 'blur' }]" >
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.Barcode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Wo_FormItem" prop="Entity.Wo" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_Wo')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.Wo" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Qty_FormItem" prop="Entity.Qty" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_Qty')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.Qty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UsedQty_FormItem" prop="Entity.UsedQty" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_UsedQty')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.UsedQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LineId_FormItem" prop="Entity.LineId" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_LineId')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.LineId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LineCode_FormItem" prop="Entity.LineCode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_LineCode')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.LineCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpId_FormItem" prop="Entity.OpId" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_OpId')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.OpId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpCode_FormItem" prop="Entity.OpCode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_OpCode')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.OpCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_FeedingTime_FormItem" prop="Entity.FeedingTime" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_FeedingTime')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.FeedingTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ScanOpId_FormItem" prop="Entity.ScanOpId" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_ScanOpId')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.ScanOpId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ScanOpCode_FormItem" prop="Entity.ScanOpCode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_ScanOpCode')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.ScanOpCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_FeedingBy_FormItem" prop="Entity.FeedingBy" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_FeedingBy')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.FeedingBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateTime_FormItem" prop="Entity.CreateTime" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_CreateTime')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.CreateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateTime_FormItem" prop="Entity.UpdateTime" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_UpdateTime')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.UpdateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_CreateBy')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.CreateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_UpdateBy')">
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.UpdateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdBatchMaterialRecord_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateProdBatchMaterialRecord.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseProdBatchMaterialRecord"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProdBatchMaterialRecordDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { prodbatchmaterialrecordApi } from '/@/api/productionmanagement/prodbatchmaterialrecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProdBatchMaterialRecord = ref();
const stateProdBatchMaterialRecord = reactive({
    vmModel: {
	  Entity:{
        MaterialCode: '',
        Barcode: '',
        Wo: '',
        Qty: null,
        UsedQty: null,
        LineId: null,
        LineCode: '',
        OpId: null,
        OpCode: '',
        FeedingTime: undefined,
        ScanOpId: null,
        ScanOpCode: '',
        FeedingBy: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
        IsValid: undefined,
        ID:null,
      },

	},
    
});

// 取消
const onCloseProdBatchMaterialRecord = () => {
    closeDialog();
};

// 提交
const onSubmitProdBatchMaterialRecord = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefProdBatchMaterialRecord.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            prodbatchmaterialrecordApi().edit(stateProdBatchMaterialRecord.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateProdBatchMaterialRecord.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProdBatchMaterialRecord.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	prodbatchmaterialrecordApi().get(stateProdBatchMaterialRecord.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateProdBatchMaterialRecord.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

